<template>
	<div>
		<el-aside width="160px" index="1">
			<!-- :default-active="$route.path" exact 精确匹配 -->
			<el-menu :default-active="$route.path" exact class="el-menu-vertical-demo" router="">
				<NavItem v-for="(v,i) in items" :key="i" :item="v" :path="v.url" />
			</el-menu>
		</el-aside>
	</div>
</template>

<script>
import NavItem from './NavItem'
export default {
	name: 'Nav',
	data() {
		return {
			items:[]
		};
	},
	props:['message'],//父传子参数
	components: {
		NavItem
	},
	created() {
		let active = localStorage.getItem('active')
		if(active == 2){
			this.items = [
				{name:'党建发布',url:'/djxc/open'},
				{name:'党务公开',url:'/djxc/release'},
				{name:'党务报告',url:'/djxc/report'}
			]
		}else if(active == 3){
			this.items = [
				{name:'在线学习',url:'/ykt/study'},
				{name:'一季一考',url:'/ykt/test'}
			]
		}
	},
	mounted() {
		// this.items = [
		// 	{name:"首页",url:'/index',icon:'el-icon-menu'},
		// 	{name:"党建宣传",url:'/djxc',icon:'el-icon-info',child:[
		// 		{name:'党建发布',url:'/djxc/open'},
		//      {name:'党务公开',url:'/djxc/release'},
		// 		{name:'党务报告',url:'/djxc/report'}
		// 	]},
		// 	{name:"云课堂",url:'/ykt',icon:'el-icon-s-help',child:[
		// 		{name:'在线学习',url:'/ykt/list'},
		// 		{name:'一季一考',url:'/ykt/test'}
		// 	]},
		// 	{name:"党建活动",url:'/djhd',icon:'el-icon-user-solid',
		// 	// child:[
		// 	// 	{name:'用户统计',url:'/djhd/stats'},
		// 	// 	{name:'角色统计',url:'/djhd/role',child:[
		// 	// 		{name:'管理员',url:'/djhd/role/administrators'},
		// 	// 		{name:'会员',url:'/djhd/role/member'}
		// 	// 	]}
		// 	// ],
		// 	},
		// ]
		
	},
	methods: {
		
	},
	watch: {
		message:function(newValue, oldValue){
			// console.log(newValue)
			if(newValue == 1){
				this.items = [
					// {name:"首页",url:'/index',icon:'el-icon-menu'}
				]
				this.$router.push({path:'/index/news'})
			}else if(newValue == 2){
				this.items = [
					{name:'党建发布',url:'/djxc/open'},
					{name:'党务公开',url:'/djxc/release'},
					{name:'党务报告',url:'/djxc/report'}
				]
				this.$router.push({path:'/djxc/open'})
			}else if(newValue == 3){
				this.items = [
					{name:'在线学习',url:'/ykt/study'},
					{name:'一季一考',url:'/ykt/test'}
				]
				this.$router.push({path:'/ykt/study'})
			}else if(newValue == 4){
				this.items = [
					// {name:"党建活动",url:'/djhd',icon:'el-icon-user-solid',
					// 	child:[
					// 		{name:'线上活动',url:'/djhd/stats'},
					// 		{name:'角色统计',url:'/djhd/role',child:[
					// 			{name:'管理员',url:'/djhd/role/administrators'},
					// 			{name:'会员',url:'/djhd/role/member'}
					// 		]}
					// 	],
					// },
				]
				this.$router.push({path:'/djhd/stats'})
			}
		},
	},
	
};
</script>
<style lang="scss" scoped>

</style>
